<?php
    include '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    
   $codci = $_REQUEST['codci'];
   $oidpa = $_REQUEST['oidpa'];
   $parteA = utf8_decode($_REQUEST['parteA']);
   $parteAB =  utf8_decode($_REQUEST['parteAB']);
   $parteE = utf8_decode($_REQUEST['parteE']);
   $parteEB = utf8_decode($_REQUEST['parteEB']);
   $lista = $_POST['lista'];
  
    
    $editar = "update ciplmedico 
              set plmpartea ='".$parteA."',
			   plmparteab ='".$parteAB."',
			   plmpartee ='".$parteE."',
			   plmparteeb ='".$parteEB."',
			   paciente ='".$oidpa."'
              where oid= '".$codci."'";
    $con->query($editar);
    
    $n = count($lista);
    $i = 0;
    
    $delete = "delete from cipres
               where ciplantilla = '".$codci."'";
    $con->query($delete);
    
    while($i < $n ){
        
        $insert2 = "insert into cipres (ciplantilla,ciprespe)values('".$codci."','".$lista[$i]."')";
        $con->query($insert2);
        $i++;
    }
     
    $con->cerrarConexion();
    
?>